﻿@{
    ViewBag.Title = "试验列表";
    Layout = "~/Views/Shared/Layout.Mobile.cshtml";
}
<style>

    td {
        border-bottom: 0.01rem solid;
        text-align: center;
        font-size: 14px;
    }

    tr {
        height: 50px;
    }
</style>
<script src="@TrialManagementTool.Helper.UrlHelper.alterContent("Scripts/mobilejs/sm-extend.min.js")"></script>
<div class="page-group">
    <div class="page page-current">
        <div class="content">
                <div class="tabs">
                    <div id="tab1" class="tab active">
                        <table style="margin-top:10px;color:#ffffff;width:100%" id="trialTable">
                            <tr>
                                <td style="width:30%;padding-left:10px">分配时间</td>
                                <td style="width:33%">产品</td>
                                <td style="width:33%">农作物</td>
                                <td></td>
                            </tr>
                        </table>
                        <div style="margin-top:10px">
                            <img style="height:14px;margin:10px;float:left;margin-right:5px" src="@TrialManagementTool.Helper.UrlHelper.alterContent("Images/Group.png")" />
                            <div>
                                <a onclick="location.href='@TrialManagementTool.Helper.UrlHelper.alterContent("TrialMobile/AddNewTrial")'" style="font-size:20px">添加试验</a>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

<script>
    function CreateElement(time, product, crop, id) {
        var content = '<tr onclick=location.href=\'' + fixUrl("TrialMobile/ShiFandian?id=" + id) + '\' ><td>' + time + '</td><td>' + product + '</td>' +
                            '<td>' + crop + '</td><td><span class="icon icon-right"></span></td></tr>';
        $("#trialTable").append(content);
    }

    $.ajax({
        url: fixUrl("api/Trial/GetTrialByPromoterID"),

        success: function (data) {
            $.each(data, function (index, value) {
                CreateElement(value.CreatedDate.substring(0, 10), value.Product, value.Crop, value.ID);
            })
        },
        error: function (data) {
            if (data.status == "401") {
                $.alert("当前用户未登录或登录超时");
            } else {
                $.alert('查询数据失败');
            }
        }
    })

</script>
